#include <iostream>
#include <vector>
using namespace std;

class segment_tree {
	vector<int> &diff;
	vector<long> isum;
	vector<long> lazyinfo;

	void lazy(int i, long v, int n)
	{
		isum[i] += v * n;
		lazyinfo[i] += v;
	}

	void down(int i, int ln, int rn)
	{
		if (lazyinfo[i]) {
			lazy(i << 1, lazyinfo[i], ln);
			lazy(i << 1 | 1, lazyinfo[i], rn);
			lazyinfo[i] = 0;
		}
	}

	void up(int i)
	{
		isum[i] = isum[i << 1] + isum[i << 1 | 1];
	}

	void build(int l, int r, int i)
	{
		if (l == r) {
			isum[i] = diff[l];
		} else {
			int mid = (l + r) >> 1;
			build(l, mid, i << 1);
			build(mid + 1, r, i << 1 | 1);
			up(i);
		}
	}

    public:
	segment_tree(int n, vector<int> &arr) : isum(n << 2, 0), lazyinfo(n << 2, 0), diff(arr)
	{
		build(1, n, 1);
	}

	void update(int jobl, int jobr, long v, int l, int r, int i)
	{
		if (jobl <= l && r <= jobr) {
			lazy(i, v, r - l + 1);
		} else {
			int mid = (l + r) >> 1;
			down(i, mid - l + 1, r - mid);
			if (jobl <= mid) {
				update(jobl, jobr, v, l, mid, i << 1);
			}
			if (mid < jobr) {
				update(jobl, jobr, v, mid + 1, r, i << 1 | 1);
			}
			up(i);
		}
	}

	long query(int jobl, int jobr, int l, int r, int i)
	{
		if (jobl <= l && r <= jobr) {
			return isum[i];
		}
		int mid = (l + r) >> 1;
		down(i, mid - l + 1, r - mid);
		long ans = 0;
		if (jobl <= mid) {
			ans += query(jobl, jobr, l, mid, i << 1);
		}
		if (mid < jobr) {
			ans += query(jobl, jobr, mid + 1, r, i << 1 | 1);
		}
		return ans;
	}
};

int main()
{
	int n = 0, m = 0;
	cin >> n >> m;
	vector<int> arr(n + 1, 0);
	for (int i = 1, pre = 0, cur, diff; i <= n; i++) {
		cin >> cur;
		diff = cur - pre;
		arr[i] = diff;
                pre = cur;
	}

	segment_tree sgt(n, arr);
	for (int i = 0, op, l, r, k, d, e; i < m; i++) {
		cin >> op;
		if (op == 1) {
			cin >> l >> r >> k >> d;
                        e = k + d * (r - l);
			sgt.update(l, l, k, 1, n, 1);
			if (l + 1 <= r) {
				sgt.update(l + 1, r, d, 1, n, 1);
			}
			if (r < n) {
				sgt.update(r + 1, r + 1, -e, 1, n, 1);
			}
		} else {
			cin >> r;
			cout << sgt.query(1, r, 1, n, 1) << '\n';
		}
	}

	return 0;
}